|
|
|
|
|
|
|
Command buttons are not very exciting when it comes to events. The event youll use 99 percent of the time is the Click() event. |
|
|
|
|
|
|
|
|
The CommandButton_Click( ) Event |
|
|
|
|
|
|
|
|
At this time, your form has two command buttons. Lets write code for each of these command buttons to perform specific actions. |
|
|
|
|
|
|
|
|
Remember that the Save button becomes enabled whenever you change data in the text boxes. If the user clicks the Save button, youll need to reset the button when the user saves the data. |
|
|
|
|
| 1. Double-click the Save command button and add the following code in the Click() event: | | Private Sub cmdSave_Click() ()
' Perform your Save routine here
cmdSave.Enabled = False End Sub |  | In this code, you see a line with a single quote () before it. This signifies a comment in Visual Basic. Youll learn how to save data from a form to a database table in a later chapter. For now, you just need to learn how to use the different events and worry about the details later. |
|
|
| Add a Click( ) Event to Unload a Form 1. Double-click the Close command button on the form. 2. Add the following code to the Click() event: | | Private Sub cmdClose_Click() ()
Unload Me
End Sub |
|
|
|